<?php


namespace app\admin\model;


class Common
{
    /**
     *  模型
     */
    protected $model;

    /**
     * 添加单条数据
     * @param $data
     * @return mixed
     * @Author:libin
     * @Time:2021/11/9 18:11
     */
    public function insert($data)
    {
        $res = $this->model->save($data);
        return $res;
//        return $this->model->save($data);
    }

    /**
     * 批量添加
     * @param $data
     * @return mixed
     * @Author:libin
     * @Time:2021/11/9 18:12
     */
    public function insertAll($data)
    {
        return $this->model->saveAll($data);
    }

    /**
     * 查询单条 数据
     * @param $where
     * @return array
     * @Author:libin
     * @Time:2021/11/9 18:16
     */
    public function fetch($where)
    {
        $result = $this->model->where($where)->find();
        return empty($result) ? [] : $result->toArray();
    }
}